#include "ParticleSystem.h"
#include <iostream>
#include <math.h>
#include "Emitter.h"
#include "Simulation.h"
#include "Reaper.h"
using namespace std;

CParticleSystem::CParticleSystem(int numberOfParticle): m_time(this, -1), m_eulerStep(0.01), m_timePreviousEulerStep(0),
										m_numberOfParticle(numberOfParticle)/*, m_applicationTime(this, 0)*/
{
	//construct the array of particle
	m_arrayOfParticles= new float[numberOfParticle*NUMBER_OF_ELEMENT_PER_PARTICLE];

	//initialise everything to -1
	for(int i=0; i<numberOfParticle*NUMBER_OF_ELEMENT_PER_PARTICLE; i++)
	{
		m_arrayOfParticles[i]=-1.f;
	}
}

CParticleSystem::~CParticleSystem(void)
{
	delete[] m_arrayOfParticles;
}

void CParticleSystem::doUpdate()
{
	if(m_timePreviousEulerStep+m_eulerStep<=m_time.getValue())
	{
		m_pointerEmitter->emitterUpdate();
		m_pointerSimulation->simulationUpdate();
		m_pointerReaper->reaperUpdate();
		m_timePreviousEulerStep=m_time.getValue();
	}
	setValue(m_arrayOfParticles);
}